﻿//+------------------------------------------------------------------+
//|                                             MetaTrader 5 Web API |
//|                   Copyright 2001-2015, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
namespace MetaQuotes.MT5WebAPI.Common
  {
  /// <summary>
  /// User data
  /// </summary>
  public class MTUser
    {
    /// <summary>
    /// client rights bit flags
    /// </summary>
    public enum EnUsersRights : ulong
      {
      USER_RIGHT_NONE = 0x0000000000000000,  // none
      USER_RIGHT_ENABLED = 0x0000000000000001,  // client allowed to connect
      USER_RIGHT_PASSWORD = 0x0000000000000002,  // client allowed to change password
      USER_RIGHT_TRADE_DISABLED = 0x0000000000000004,  // client trading disabled
      USER_RIGHT_INVESTOR = 0x0000000000000008,  // client is investor
      USER_RIGHT_CONFIRMED = 0x0000000000000010,  // client certificate confirmed
      USER_RIGHT_TRAILING = 0x0000000000000020,  // trailing stops are allowed
      USER_RIGHT_EXPERT = 0x0000000000000040,  // expert advisors are allowed
      USER_RIGHT_API = 0x0000000000000080,  // client API are allowed
      USER_RIGHT_REPORTS = 0x0000000000000100,  // trade reports are allowed
      USER_RIGHT_READONLY = 0x0000000000000200,  // client is readonly
      USER_RIGHT_RESET_PASS = 0x0000000000000400,  // client must change password at next login
      //--- enumeration borders
      USER_RIGHT_DEFAULT = USER_RIGHT_ENABLED | USER_RIGHT_PASSWORD | USER_RIGHT_TRAILING | USER_RIGHT_EXPERT | USER_RIGHT_REPORTS,
      USER_RIGHT_ALL = USER_RIGHT_ENABLED | USER_RIGHT_PASSWORD | USER_RIGHT_TRADE_DISABLED |
      USER_RIGHT_INVESTOR | USER_RIGHT_CONFIRMED | USER_RIGHT_TRAILING |
      USER_RIGHT_EXPERT | USER_RIGHT_API | USER_RIGHT_REPORTS |
      USER_RIGHT_READONLY | USER_RIGHT_RESET_PASS
      };
    /// <summary>
    /// password types
    /// </summary>
    public enum EnUsersPasswords : uint
      {
      USER_PASS_MAIN = 0,
      USER_PASS_INVESTOR = 1,
      USER_PASS_API = 2,
      //--- 
      USER_PASS_FIRST = USER_PASS_MAIN,
      USER_PASS_LAST = USER_PASS_API,
      };
    /// <summary>
    /// connection types
    /// </summary>
    public enum EnUsersConnectionTypes : uint
      {
      /// <summary>
      /// client types
      /// </summary>
      USER_TYPE_CLIENT = 0,
      USER_TYPE_CLIENT_WINMOBILE = 1,
      USER_TYPE_CLIENT_WINPHONE = 2,
      USER_TYPE_CLIENT_IPHONE = 4,
      USER_TYPE_CLIENT_ANDROID = 5,
      USER_TYPE_CLIENT_BLACKBERRY = 6,
      /// <summary>
      /// manager types
      /// </summary>
      USER_TYPE_ADMIN = 32,
      USER_TYPE_MANAGER = 33,
      USER_TYPE_MANAGER_API = 34,
      USER_TYPE_ADMIN_API = 36,
      /// <summary>
      /// enumeration borders
      /// </summary>
      USER_TYPE_FIRST = USER_TYPE_CLIENT,
      USER_TYPE_LAST = USER_TYPE_ADMIN_API
      };
    /// <summary>
    /// login
    /// </summary>
    public ulong Login { get; set; }
    /// <summary>
    /// group
    /// </summary>
    public string Group { get; set; }
    /// <summary>
    /// certificate serial number
    /// </summary>
    public ulong CertSerialNumber { get; set; }
    /// <summary>
    /// EnUsersRights
    /// </summary>
    public EnUsersRights Rights { get; set; }
    /// <summary>
    /// registration datetime (filled by MT5)
    /// </summary>
    public long Registration { get; set; }
    public long LastAccess { get; set; }
    public string LastIP { get; set; }
    /// <summary>
    /// name
    /// </summary>
    public string Name { get; set; }
    /// <summary>
    /// company
    /// </summary>
    public string Company { get; set; }
    /// <summary>
    /// external system account (exchange, ECN, etc)
    /// </summary>
    public string Account { get; set; }
    /// <summary>
    /// country
    /// </summary>
    public string Country { get; set; }
    /// <summary>
    /// client language (WinAPI LANGID)
    /// </summary>
    public uint Language { get; set; }
    /// <summary>
    /// city
    /// </summary>
    public string City { get; set; }
    /// <summary>
    /// state
    /// </summary>
    public string State { get; set; }
    /// <summary>
    /// ZIP code
    /// </summary>
    public string ZIPCode { get; set; }
    /// <summary>
    /// address
    /// </summary>
    public string Address { get; set; }
    /// <summary>
    /// phone
    /// </summary>
    public string Phone { get; set; }
    /// <summary>
    /// email
    /// </summary>
    public string Email { get; set; }
    /// <summary>
    /// additional ID
    /// </summary>
    public string ID { get; set; }
    /// <summary>
    /// additional status
    /// </summary>
    public string Status { get; set; }
    /// <summary>
    /// comment
    /// </summary>
    public string Comment { get; set; }
    /// <summary>
    /// color
    /// </summary>
    public uint Color { get; set; }
    /// <summary>
    /// main password
    /// </summary>
    public string MainPassword { get; set; }
    /// <summary>
    /// invest password
    /// </summary>
    public string InvestPassword { get; set; }
    /// <summary>
    /// phone password
    /// </summary>
    public string PhonePassword { get; set; }
    /// <summary>
    /// leverage
    /// </summary>
    public uint Leverage { get; set; }
    /// <summary>
    /// agent account
    /// </summary>
    public ulong Agent { get; set; }
    /// <summary>
    /// balance
    /// </summary>
    public double Balance { get; set; }
    /// <summary>
    /// credit
    /// </summary>
    public double Credit { get; set; }
    /// <summary>
    /// accumulated interest rate
    /// </summary>
    public double InterestRate { get; set; }
    /// <summary>
    /// accumulated daily commissions
    /// </summary>
    public double CommissionDaily { get; set; }
    /// <summary>
    /// accumulated monthly commissions
    /// </summary>
    public double CommissionMonthly { get; set; }
    /// <summary>
    /// accumulated daily agent commissions
    /// </summary>
    public double CommissionAgentDaily { get; set; }
    /// <summary>
    /// accumulated  monthly agent commissions
    /// </summary>
    public double CommissionAgentMonthly { get; set; }
    /// <summary>
    /// previous balance state day
    /// </summary>
    public double BalancePrevDay { get; set; }
    /// <summary>
    /// previous balance state month
    /// </summary>
    public double BalancePrevMonth { get; set; }
    /// <summary>
    /// previous equity state day
    /// </summary>
    public double EquityPrevDay { get; set; }
    /// <summary>
    /// previous equity state month
    /// </summary>
    public double EquityPrevMonth { get; set; }
    /// <summary>
    /// last password change datetime (filled by MT5)
    /// </summary>
    public long LastPassChange { get; set; }
    /// <summary>
    /// Create user with default values
    /// </summary>
    public static MTUser CreateDefault()
      {
      MTUser user = new MTUser();
      //---
      user.Rights = EnUsersRights.USER_RIGHT_ENABLED | EnUsersRights.USER_RIGHT_PASSWORD | EnUsersRights.USER_RIGHT_TRAILING | EnUsersRights.USER_RIGHT_EXPERT | EnUsersRights.USER_RIGHT_API | EnUsersRights.USER_RIGHT_REPORTS;
      user.Leverage = 100;
      user.Color = 0xFF000000;
      //---
      return user;
      }
    }
  }
